package com.wk.jetpackdemo

import android.databinding.DataBindingUtil
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.DividerItemDecoration
import android.support.v7.widget.LinearLayoutManager
import com.wk.jetpackdemo.databinding.ActivityPaoBinding
import com.wk.jetpackdemo.model.PaoViewModel
import com.wk.jetpackdemo.recyclerview.PaoAdapter

class PaoActivity : AppCompatActivity() {
    protected val mBinding by lazy {
        DataBindingUtil.setContentView<ActivityPaoBinding>(this, getLayoutId())
    }

    private fun getLayoutId(): Int {
        return R.layout.activity_pao
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val paoViewModel = PaoViewModel()
        mBinding.setVariable(BR.model, paoViewModel)
        mBinding.recycler.let {
            it.adapter = PaoAdapter(paoViewModel.articleList)
            it.layoutManager = LinearLayoutManager(this)
            it.addItemDecoration(DividerItemDecoration(this,LinearLayoutManager.VERTICAL))
        }
        paoViewModel.loadData(1)
    }
}
